package com.rabbit.eap.controller.system;

import com.rabbit.eap.framework.common.api.ApiResult;
import com.rabbit.eap.framework.common.controller.BaseController;
import com.rabbit.eap.framework.core.validator.groups.AddGroup;
import com.rabbit.eap.framework.core.validator.groups.UpdateGroup;
import com.rabbit.eap.framework.log.annotation.Module;
import com.rabbit.eap.framework.log.annotation.OperationLog;
import com.rabbit.eap.framework.log.enums.OperationLogType;
import com.rabbit.eap.system.dto.SysNoticeDTO;
import com.rabbit.eap.system.param.SysNoticePageParam;
import com.rabbit.eap.system.service.ISysNoticeService;
import com.rabbit.eap.system.vo.SysNoticeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @projectName: eap
 * @packageName: com.rabbit.eap.system.controller
 * @className: SysNoticeController
 * @author： rabbit
 * @version： 1.0
 * @since： 2020/06/06 23:01:20
 * <p>Description:
 * 通知公告表 控制器
 * </p>

 */
@Slf4j
@RestController
@RequestMapping("/system/sysNotice")
@Module("system")
@Api(value = "通知公告表API", tags = {"通知公告表"})
public class SysNoticeController extends BaseController {

    @Autowired
    private ISysNoticeService sysNoticeService;


    /**
     * @param sysNoticeDTO:sysNoticeDTO数据传输对象
     * @Description: 添加通知公告表
     * @methodName: saveSysNotice
     * @return: ApiResult.result(flag)
     * @date: 2020/06/06 23:01:20
     * @author: rabbit
     */
    @PostMapping("/saveSysNotice")
    @RequiresPermissions("sys:notice:add")
    @OperationLog(name = "添加通知公告表", type = OperationLogType.ADD)
    @ApiOperation(value = "添加通知公告表", response = ApiResult.class)
    public ApiResult saveSysNotice(@Validated(AddGroup.class) @RequestBody SysNoticeDTO sysNoticeDTO) throws Exception {
        ApiResult apiResult = sysNoticeService.saveSysNotice(sysNoticeDTO);
        return apiResult;
    }

    /**
     * @param sysNoticeDTO:sysNoticeDTO数据传输对象
     * @Description: 修改通知公告表
     * @methodName: modifySysNotice
     * @return: ApiResult
     * @date: 2020/06/06 23:01:20
     * @author: rabbit
     */
    @PutMapping("/modifySysNotice")
    @RequiresPermissions("sys:notice:edit")
    @OperationLog(name = "修改通知公告表", type = OperationLogType.UPDATE)
    @ApiOperation(value = "修改通知公告表", response = ApiResult.class)
    public ApiResult modifySysNotice(@Validated(UpdateGroup.class) @RequestBody SysNoticeDTO sysNoticeDTO) throws Exception {
        ApiResult apiResult = sysNoticeService.modifySysNotice(sysNoticeDTO);
        return apiResult;
    }

    /**
     * @param ids:id集合
     * @Description: 删除通知公告表
     * @methodName: removeSysNotice
     * @return: ApiResult
     * @date: 2020/06/06 23:01:20
     * @author: rabbit
     */
    @DeleteMapping("/removeSysNotice")
    @RequiresPermissions("sys:notice:remove")
    @OperationLog(name = "删除通知公告表", type = OperationLogType.DELETE)
    @ApiOperation(value = "删除通知公告表", response = ApiResult.class)
    public ApiResult removeSysNotice(@RequestParam("ids") Long[] ids) throws Exception {
        ApiResult apiResult = sysNoticeService.removeSysNotice(ids);
        return apiResult;
    }

    /**
     * @param id: id
     * @Description: 根据Id获取通知公告表详情
     * @methodName: getSysNoticeInfo
     * @return: ApiResult
     * @date: 2020/06/06 23:01:20
     * @author: rabbit
     */
    @GetMapping("/getSysNoticeInfo")
    @RequiresPermissions("sys:notice:query")
    @OperationLog(name = "通知公告表详情", type = OperationLogType.INFO)
    @ApiOperation(value = "通知公告表详情", response = SysNoticeVO.class)
    public ApiResult getSysNoticeInfo(@RequestParam("id") Long id) throws Exception {
        ApiResult apiResult = sysNoticeService.getSysNoticeById(id);
        return apiResult;
    }

    /**
     * @param sysNoticePageParam
     * @Description: 通知公告表分页列表
     * @methodName: getSysNoticePageList
     * @return: ApiResult
     * @date: 2020/06/06 23:01:20
     * @author: rabbit
     */
    @GetMapping("getSysNoticePageList")
    @RequiresPermissions("sys:notice:list")
    @OperationLog(name = "通知公告表分页列表", type = OperationLogType.PAGE)
    @ApiOperation(value = "通知公告表分页列表", response = SysNoticeVO.class)
    public ApiResult getSysNoticePageList(SysNoticePageParam sysNoticePageParam) throws Exception {
        ApiResult apiResult = sysNoticeService.getSysNoticePageList(sysNoticePageParam);
        return apiResult;
    }

}

